package com.demo.myapplication.mvp.model;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class SettingInfo {
  private static final String TAG = "SettingInfo";

  private Context mContext;
  private SharedPreferences sp;
  private static String KEY_NAME = "username";
  private static String KEY_PWD = "password";

  private static class INSTANCE {
    private static final SettingInfo INSTANCE = new SettingInfo();
  }

  private SettingInfo() {

  }

  public static SettingInfo getInstance() {
    return INSTANCE.INSTANCE;
  }

  public void init(Context context) {
    this.mContext = context.getApplicationContext();
    sp = PreferenceManager.getDefaultSharedPreferences(mContext);
    sp.edit().putString(KEY_NAME, "admin").apply();
    sp.edit().putString(KEY_PWD, "admin").apply();
  }

  public String getName() {
    return sp.getString(KEY_NAME, null);
  }

  public String getPwd() {
    return sp.getString(KEY_PWD, null);
  }
}
